<?php

namespace bc\model;

use bc\ar\MActiveRecord;

class BankcardModel extends MActiveRecord
{
	
		/**
		 * bc_bank_card表
		 */
		public $autoId = 'card_id';
		public static function tableName()
		{
			return '{{%bank_card}}';
		}
        
        public function getCardInfo($params)
        {       
                $this->columns = "bc_bank_card.card_id,bc_bank_card.card_number,bc_bank.bank_name,bc_account.balance";
                $ar = $this->find ()->select($this->columns)
				->leftJoin('bc_bank', 'bc_bank'. '.bank_id = ' . self::getTableSchema()->name . '.bank_id')
                                ->leftJoin('bc_account', 'bc_account'. '.user_id = ' . self::getTableSchema()->name . '.user_id')
				->where($params);

		return $ar->asArray()->one();
        }


		/**
		 * Created by Mr.hu.
		 * @param $uid 用户的id
		 * Description：检查某一用户是否已经绑定了银行卡
		 */
		public function isBindBankByUid($uid)
		{
			$list=self::find()->where(['user_id'=>$uid,'is_del'=>0])->asArray()->all();
			return count($list)>0?'1':'0';
		}
        
       
}



